package com.example.demofdfs;

import java.util.Collection;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableMBeanExport;
import org.springframework.context.annotation.Import;
import org.springframework.jmx.support.RegistrationPolicy;
import org.springframework.scheduling.annotation.EnableScheduling;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

import com.example.demofdfs.filter.MyFilter;
import com.example.demofdfs.web.HelloServlet;
import com.github.tobato.fastdfs.FdfsClientConfig;

@Import(FdfsClientConfig.class)
//解决jmx重复注册bean的问题
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
@MapperScan("com.example.demofdfs.mapper")
@EnableScheduling
@EnableSwagger2
@EnableDiscoveryClient
@SpringBootApplication
public class DemoFdfsApplication implements CommandLineRunner {
	
	//http://localhost:8080/swagger-ui.html
	
	public static void main(String[] args) {
		SpringApplication.run(DemoFdfsApplication.class, args);
	}

	@Bean
	public MyFilter myFilter() {
		return new MyFilter();
	}
	
	@Bean
	public HelloServlet helloServlet() {
		return new HelloServlet();
	}
	
	@Override
	public void run(String... args) throws Exception {
		// TODO Auto-generated method stub
//		System.out.println("run...");
//		test_2();
	}
	
	public void test_2() {
		Map<String, String> envs = System.getenv();
		System.out.println(envs);
		Set<String> keys = envs.keySet();
		Collection<String> collection = envs.values();
		System.out.println(keys);
		System.out.println(collection);
		System.out.println(envs.getClass());
		envs.forEach((k, v)-> System.out.println(k + " = " + v));
		System.out.println("\n=========================================\n");
		
		Properties prop = System.getProperties();
		prop.forEach((k, v)-> System.out.println(k + " = " + v));
	}
}
